ens = "wigwrkaugala"
# print(len(ens))  # 12

a_a = [21, 4, 24, 25, 20, 5, 15, 9, 17, 6, 13, 3, 18,
       12, 10, 19, 0, 22, 2, 11, 23, 1, 8, 7, 14, 16]
a_b = "abcdefghijklmnopqrstuvwxyz"
a_d = 0
b_a = [17, 23, 7, 22, 1, 16, 6, 9, 21, 0, 15, 5, 10,
       18, 2, 24, 4, 11, 3, 14, 19, 12, 20, 13, 8, 25]
b_b = "abcdefghijklmnopqrstuvwxyz"
b_d = 0
flag = ""
for rech in ens:
    f = 0
    for ch in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
        n1 = b_b.find(ch)
        if n1 == -1:
            continue
        n2 = b_a.index(n1)
        if n2 == -1:
            continue
        n3 = a_a.index(n2)
        if n3 == -1:
            continue
        if a_b[n3] == rech:
            flag += ch
            f = 1
            # 找到字符了b类数组左移一位
            b_a = b_a[1:] + b_a[:1]
            b_b = b_b[1:] + b_b[:1]
            b_d += 1
            # 循环达到25次a类数组左移一位
            a_d += 1
            if a_d == 25:
                a_a = a_a[1:] + a_a[:1]
                a_d = 0
            break
    if f == 0:
        flag += "#"
print("flag{" + flag + "}")

# 逆向后的代码实现
s_b2 = [17, 23, 7, 22, 1, 16, 6, 9, 21, 0, 15, 5, 10, 18, 2, 24, 4, 11, 3, 14, 19, 12, 20, 13, 8, 25]
s_a3 = [21, 4, 24, 25, 20, 5, 15, 9, 17, 6, 13, 3, 18, 12, 10, 19, 0, 22, 2, 11, 23, 1, 8, 7, 14, 16]
b = "abcdefghijklmnopqrstuvwxyz"
s3 = "wigwrkaugala"
re1 = []
for i in s3:
    re1.append(s_a3[b.index(i)])
print(re1)
flag = ''
for i in re1:
    s4 = s_b2[i]
    flag += b[s4]
    s_b2.append(s_b2[0])
    s_b2.remove(s_b2[0])
    b += b[0]
    b = b[1:]
flag = 'flag{' + flag + '}'
print(flag)
